#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n = 0;
    int q = 0;
    cin >> n >> q;
    vector<int> arr(n);
    vector<long long> dp(n + 1, 0);

    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];

        dp[i + 1] = dp[i] + arr[i];

    }

    int l;
    int r;

    while (q--)
    {
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
}